<?php

class Users_Model extends CI_Model {
	
	public function __construct()
	{
		parent::__construct();
		$this->load->database();
	}
	
	public function login($username, $password)
	{
		$salt = md5($password);	
		$query = $this->db->get_where('users', array('username'=>$username, 'password'=>sha1($salt.$password)));
		return $query->result();
	}
	
	public function get()
	{
		$query = $this->db->get('users');
		return $query->result();
	}
	
	public function insert($input)
	{
		$salt = md5($input['password']);
		$input['password'] = sha1($salt.$input['password']);
		$query = $this->db->insert('users', $input);
	}
	
	public function update($input, $id)
	{
		$salt = md5($input['password']);
		$input['password'] = sha1($salt.$input['password']);
		$query = $this->db->update('users', $input, array('id'=>$id));
		return $query; 
	}
	
	public function delete($id)
	{
		$query = $this->db->delete('users', array('id'=>$id));
		return $query;
	}
}

/* End of file users.php */
/* Location: ./application/models/users.php */